%define loc 0x1000 ; where to load sector
%define drive 0x80
%define stage2 0x02 ; sector of cmdline
[bits 16]
[org 0]

jmp 0x7C0:start

start:

	mov ax,cs
	mov ds,ax
	mov es,ax


	mov si,welcome ; print out welcome msg
	call print

	;mov ah, 0 ; Wait for keypress
	;int 16h

	; setup booting stage 2
	mov cl, stage2
	mov ax, loc
	mov es, ax
	mov al, 1 ; number of sectors
	
	call loadsector
	
	jmp loc:0000;

hang:
	call hang
	;jmp loc:0000 ; jump to our os


done:
	jmp $

loadsector:
	mov bx,0
	mov dl, drive ; drive
	mov dh,0 ; head
	mov ch,0 ; track
	;mov cl, cmdline
	mov ah,2
	int 0x13
	jc err
	ret
err:
	mov si,errmsg
	call print
	ret
print:
	mov bp,sp
	cont:
		lodsb
		or al,al
		jz dne
		mov ah,0x0e
		mov bx,0
		int 10h
		jmp cont
dne:
	mov sp,bp
	ret

welcome db "Loading LevOS 1.6",10,13,0

errmsg db "Error loading LevOS16",10,13,0
times 510 - ($-$$) db 0
dw 0xaa55